package hz.mobileproject.pda.ui.adapter;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.View;
import android.widget.ImageView;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.entity.Photo;
import hz.mobileproject.pda.ui.base.BaseCustomAdapter;

/**
 * Created by Lc on 2017/11/16.
 */

public class DeptCheckGVAdapter extends BaseCustomAdapter<Photo, DeptCheckGVAdapter.TempViewHolder> {


    public DeptCheckGVAdapter(Context mContext, List<Photo> photos) {
        super(mContext, photos);
    }

    @Override
    public int getCount() {
        return mList.size() + 1;
    }

    @Override
    protected int bindView() {
        return R.layout.item_photo_ingv;
    }

    @Override
    protected TempViewHolder createViewHolder() {
        return new TempViewHolder();
    }

    @Override
    protected void bindData(int position, View convertView, TempViewHolder viewHolder) {
        if (position >= mList.size()) {
            viewHolder.iv.setImageBitmap(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.plus));
        } else {
            x.image().bind(viewHolder.iv, mList.get(position).getPath());
        }
    }


    class TempViewHolder {
        @ViewInject(R.id.iv_photo)
        private ImageView iv;
    }
}
